<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        /*
            投资的年利率为5%，求从1000增长到5000，需要多少年
        */
       var money = 1000,i = 0;
       while(money<5000){
           money = money*1.05;
           i++;
       }
       document.write("一共需要"+ i +"年")
    </script>
</head>
<body>
    
</body>
</html>